#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class Solution {
    string path;
    vector<string> ret;
public:
    vector<string> letterCasePermutation(string s) {
        dfs(s, 0);
        return ret;
    }
    void dfs(string& s, int pos)
    {
        if (s.size() == pos)
        {
            ret.push_back(path);
            return;
        }
        char a = s[pos];
        path.push_back(a);
        dfs(s, pos + 1);
        path.pop_back();
        if (a < '0' || a>'9')
        {
            a = change(a);
            path.push_back(a);
            dfs(s, pos + 1);
            path.pop_back();
        }
    }
    char change(char s)
    {
        if (s >= 'a' && s <= 'z')
            s -= 32;
        else
        {
            s += 32;
        }
        return s;
    }
};